part of '../index.dart';

class CustomPullScrollView extends StatelessWidget {
  final EasyRefreshController controller;
  final bool refreshOnStart;
  final ERChildBuilder? builder;
  final void Function()? onRefresh;
  final void Function()? onLoading;

  const CustomPullScrollView({
    super.key,
    required this.controller,
    this.refreshOnStart = true,
    this.onRefresh,
    this.onLoading,
    this.builder,
  });

  @override
  Widget build(BuildContext context) {
    return EasyRefresh.builder(
      header: ClassicHeader(
        showText: false,
        iconDimension: 100.w,
        succeededIcon: const LoadFinish(),
        progressIndicatorSize: 15,
        progressIndicatorStrokeWidth: 1.5,
        iconTheme: IconThemeData(color: const Color(0xFF9299B1), size: 18.w),
      ),
      footer: const ClassicFooter(
        showText: false,
        noMoreIcon: Text(
          'THE END',
          style: TextStyle(fontSize: 10, color: Color(0xFFDFDFDF)),
        ),
      ),
      controller: controller,
      onRefresh: onRefresh,
      onLoad: onLoading,
      refreshOnStart: refreshOnStart,
      childBuilder: builder,
    );
  }
}

class LoadFinish extends StatelessWidget {
  const LoadFinish({super.key});

  @override
  Widget build(BuildContext context) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Image.asset(Images.icChatLoadFinish, width: 14.w),
        Text(
          ' ${T.current.c_load_finish}',
          style: TextStyle(color: const Color(0xFF9299B1), fontSize: 11.w),
        ),
      ],
    );
  }
}
